<?php
    date_default_timezone_set('PRC');
    $ipaName = "";
    $dicpath = dirname(__FILE__);
    $filesArray = scandir($dicpath);
    function get_extension($file)
    {
        return substr(strrchr($file, '.'), 1);
    }

    foreach ($filesArray as $value) {
        if (get_extension($value) == 'ipa'){ 
            $ipaName = $value;
        }
    }
    $filepath = $dicpath."/".$ipaName;
    // echo $filepath;
        $mtime = date("m-d H:i",filemtime($filepath));
        // echo $mtime;
    $pathArray = pathinfo($_SERVER['PHP_SELF']);
            // $pathArray = pathinfo("/debugapps/iphone/772/debug/info2.php");

    $urlPath = $pathArray["dirname"];
        // echo $urlPath;
    // echo $ipapath;
    $explodeArray = explode("/",$urlPath);

    $last3Array = array_slice($explodeArray,-3);
    $abc = join("_",$last3Array);
    $plistName = $abc.".plist";
    $ipapath = join("/",$last3Array)."/".$ipaName;
    $appurl = "itms-services://?action=download-manifest&url=https://coding.net/u/dacaiguoguo/p/install/git/raw/master/plist2/".$plistName;
    if(isset($_GET["updatetime"]) && count($_GET) > 0 ){
        header('Content-type: text/json');
        $jarr = array('updatetime' => $mtime,'ipa' => $ipapath,'appurl' => $appurl);
        echo $str = json_encode($jarr);
    } else {
        $info = file_get_contents("info.html");
        echo $info;
    }
?>

